Dynomotion

Group: DynoMotion Message: 13043 From: Moray Cuthill Date: 4/1/2016
Subject: Tool setting program hanging on GetDROs
My next problem.
The following is my program for setting my tool Z offsets/length, and it hangs on the GetDROs line.
Any suggestions?

I've just had a quick look at the ToolTableSet.c example, and I see it uses getMachine instead. It's been a couple months since I wrote this, so I'm not entirely sure why I opted for GetDROs...


#include "KMotionDef.h"
#include "cyclone.h"
#include "KflopToKMotionCNCFunctions.c"
main()
{
 printf("ToolSetZ.c started\n");
 int Units, TWORD, HWORD, DWORD;
 double DROx, DROy, DROz, DROa, DROb, DROc, OffsetZ;
 double ZMeasured, ZDiff, ZNewOffset;
 // get current DRO reading (we only need X, but we have to handle them all)
 printf("Just about to GetDROs\n");
 GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
 printf("GetDros done\n");
 // get the current Units and ToolTblID (and ignore the H and D Words)
 GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
 printf("GetMiscSettings done\n");
 // if KMotionCNC is in inch/G20 mode, then quit as it shouldn't be
 if(Units == CANON_UNITS_INCHES){
  MsgBox("KMotion set to inches. Set to MM and retry",MB_OK|MB_ICONEXCLAMATION);
  ThreadDone();
 }
 // get the Z offset from the tool table using the TWORD as index
 GetToolLength(TWORD, &OffsetZ);
 printf("GetToolLength done\n");
 // now we have those, ask the operator for the actual size
 int Answer = InputBox("Enter Z offset in MM (normally 0 if touching off)",&ZMeasured);
 if(Answer) { // if true/1, then user cancelled
  MsgBox("Z Offset adjustment cancelled",MB_OK|MB_ICONEXCLAMATION);
  ThreadDone();  // and kill the thread
 } else { // else we got a value and need to do some calcs
  // first up we'll calculate the difference
  ZDiff = DROz - ZMeasured;
  // then the new offset with some rounding
  ZNewOffset = RoundToReasonable(OffsetZ - ZDiff,Units);
  // and finally update the tool table
  SetToolLength(TWORD, ZNewOffset);
 }
}

Thanks,
Moray